package SpellCheck;

import java.util.List;

public class CommonUtilities {

	/**
	 * Checks for equality between two objects 
	 * @param obj1
	 * @param obj2
	 * @return boolean
	 * 
	 * Equality check done here.
	 */
	public static boolean checkEquality(Object obj1, Object obj2) {
        boolean isEqual;

        if (obj1 == obj2) {
            isEqual = true;
        } else if (obj1 != null) {
        	// Checks if these two objects are equal on the basis of contract
			// specified in the implementation of equals method
            isEqual = obj1.equals(obj2);
        } else if (obj2 != null) {
            // obj1 is null while obj2 is not null
            isEqual = false;
        } else {
            // both are null
            isEqual = true;
        }
        return isEqual;
    }
	
	/**
	 * Returns an appended list of string 
	 * @param str 
	 * @return
	 */
	public static String appendString(List<String> str)
	{
		StringBuffer sbf = new StringBuffer();
		int i =0;

		if(null == str || str.size()<1){			
			return "";
		}
		
		int k = str.size();
		while(i<k){
			sbf.append(str.get(i));
			sbf.append(":");			
			i++;
		}
		return sbf.toString();
	}
	
}
